package by.airlanterns.dto;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.Fetch;
import org.hibernate.validator.constraints.NotEmpty;

import javax.persistence.*;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: Sergey
 * Date: 27.01.13
 * Time: 17:12
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "category")
public class Category {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id_category")
    private Integer idCategory;

    @OneToMany(mappedBy = "category", fetch = FetchType.EAGER)
    @Fetch(value = org.hibernate.annotations.FetchMode.SELECT)
    @Cascade(value = org.hibernate.annotations.CascadeType.ALL)
    @JsonIgnore
    private Set<Lantern> lanterns;

    @Column(name = "category_title")
    @NotEmpty
    private String categoryTitle;

    public Set<Lantern> getLanterns() {
        return lanterns;
    }

    public void setLanterns(Set<Lantern> lanterns) {
        this.lanterns = lanterns;
    }

    public String getCategoryTitle() {
        return categoryTitle;
    }

    public void setCategoryTitle(String categoryTitle) {
        this.categoryTitle = categoryTitle;
    }

    public Integer getIdCategory() {
        return idCategory;
    }

    public void setIdCategory(Integer idCategory) {
        this.idCategory = idCategory;
    }
}
